﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var baotypeData = Jxstar.findComboData('baotype');
	var plantypeData = Jxstar.findComboData('plantype');
	var moneytypeData = Jxstar.findComboData('moneytype');
	var authtypeData = Jxstar.findComboData('authtype');
	var yesnoData = Jxstar.findComboData('yesno');
	var planyearData = Jxstar.findComboData('planyear');
	var planstatusData = Jxstar.findComboData('planstatus');

	var cols = [
	{col:{header:'计划包属性', width:28, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: baotypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: baotypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < baotypeData.length; i++) {
				if (baotypeData[i][0] == value)
					return baotypeData[i][1];
			}
		}}, field:{name:'money_plan__bao_type',type:'string'}},
	{col:{header:'计划编号', width:94, sortable:true}, field:{name:'money_plan__plan_code',type:'string'}},
	{col:{header:'项目名称', width:185, sortable:true}, field:{name:'money_plan__plan_name',type:'string'}},
	{col:{header:'主要内容与申请理由', width:260, sortable:true, hidden:true}, field:{name:'money_plan__plan_desc',type:'string'}},
	{col:{header:'计划类型', width:78, sortable:true, hidden:true, align:'center',
		renderer:function(value){
			for (var i = 0; i < plantypeData.length; i++) {
				if (plantypeData[i][0] == value)
					return plantypeData[i][1];
			}
		}}, field:{name:'money_plan__plan_type',type:'string'}},
	{col:{header:'项目类别', width:119, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'money_plan__money_type',type:'string'}},
	{col:{header:'预计总投资(万元)', width:114, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__plan_money',type:'float'}},
	{col:{header:'当年预计付款(万元)', width:129, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__year_money',type:'float'}},
	{col:{header:'*投资计划批复文号', width:160, sortable:true, editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.TextField({
			maxLength:100, allowBlank:false
		})}, field:{name:'money_plan__check_fileno',type:'string'}},
	{col:{header:'*投资计划批文名称', width:168, sortable:true, editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.TextField({
			maxLength:150, allowBlank:false
		})}, field:{name:'money_plan__check_name',type:'string'}},
	{col:{header:'授权形式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: authtypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: authtypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < authtypeData.length; i++) {
				if (authtypeData[i][0] == value)
					return authtypeData[i][1];
			}
		}}, field:{name:'money_plan__auth_type',type:'string'}},
	{col:{header:'主管部门', width:114, sortable:true}, field:{name:'money_plan__done_deptname',type:'string'}},
	{col:{header:'是否结转', width:60, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__is_turn',type:'string'}},
	{col:{header:'立项批复日期', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_checkdate',type:'date'}},
	{col:{header:'立项批复金额(万元)', width:121, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__project_money',type:'float'}},
	{col:{header:'授权时间', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__auth_date',type:'date'}},
	{col:{header:'授权登记人', width:75, sortable:true}, field:{name:'money_plan__auth_user',type:'string'}},
	{col:{header:'型号规格', width:100, sortable:true}, field:{name:'money_plan__device_size',type:'string'}},
	{col:{header:'单位', width:58, sortable:true}, field:{name:'money_plan__plan_unit',type:'string'}},
	{col:{header:'数量', width:51, sortable:true, renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__plan_num',type:'float'}},
	{col:{header:'单价(万元)', width:73, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__plan_price',type:'float'}},
	{col:{header:'预计实施时间', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_period',type:'string'}},
	{col:{header:'预算年度', width:64, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planyearData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planyearData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planyearData.length; i++) {
				if (planyearData[i][0] == value)
					return planyearData[i][1];
			}
		}}, field:{name:'money_plan__plan_year',type:'string'}},
	{col:{header:'申报日期', width:82, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__plan_date',type:'date'}},
	{col:{header:'申报人', width:73, sortable:true}, field:{name:'money_plan__plan_user',type:'string'}},
	{col:{header:'申报部门', width:100, sortable:true}, field:{name:'money_plan__dept_name',type:'string'}},
	{col:{header:'计划状态', width:90, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatusData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planstatusData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatusData.length; i++) {
				if (planstatusData[i][0] == value)
					return planstatusData[i][1];
			}
		}}, field:{name:'money_plan__plan_status',type:'string'}},
	{col:{header:'备注', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_memo',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_id',type:'string'}},
	{col:{header:'申报人ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_userid',type:'string'}},
	{col:{header:'申报部门ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__dept_id',type:'string'}},
	{col:{header:'主管部门ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__done_deptid',type:'string'}},
	{col:{header:'授权人登记id', width:100, sortable:true, hidden:true}, field:{name:'money_plan__auth_userid',type:'string'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '1',
		funid: 'money_authdo'
	};
	
	//定义包标志列	cols[0].col.header = '';	cols[0].col.width = 28;	cols[0].col.renderer = function(val, meta, rec) {		var html = '';		var parentId = rec.get('money_plan__plan_id');		var baotype = rec.get('money_plan__bao_type');		var isturn = rec.get('money_plan__is_turn');		var imgname = 'folder' + baotype + '.gif';		if (baotype == '1' || baotype == '2') {			html = '<img src="resources/images/exp/'+ imgname +'" style="cursor:pointer;" title="点击查看子计划" '+				   'onClick="JxPm.showSubPlan(\''+ parentId +'\', \'money_bao_sub\', \''+ isturn +'\', \'money_authdo\');"></img>';		}		return html;	};		config.eventcfg = {		moreCheck: function(){			var records = this.grid.getSelectionModel().getSelections();			if (!JxUtil.selected(records)) return;						var planids = '';			for (var i = 0; i < records.length; i++) {				var planid = records[i].get('money_plan__plan_id');				planids += '&keyid=' + planid			}						this.createCheckWindow(planids);		},				exeCheck: function(planids, form) {						var params = 'funid=money_authdo' + planids;			params += JxUtil.getFormValues(form, false);			params += '&pagetype=editgrid&eventcode=moreCheck';						var self = this;			var endcall = function(data) {				//重新加载数据				self.grid.getStore().reload();			};			//发送请求			Request.postRequest(params, endcall);		},				/**		* private 创建批复下达对话框		*		* planids -- 批量选择的投资计划ID		**/		createCheckWindow: function(planids) {			var printForm = new Ext.form.FormPanel({				id: 'node_money_auth_form',				style: 'padding:20px;',				border: false,				frame: false,				layout:'form',				baseCls: 'x-plain',				items: [					{xtype:'textfield', fieldLabel:'批复文号', name:'money_plan__check_fileno', readOnly:false, allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%', maxLength:50},					{xtype:'textfield', fieldLabel:'批复文件名', name:'money_plan__check_name', readOnly:false, allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%', maxLength:50},					{xtype:'hidden', fieldLabel:'授权人id', name:'money_plan__auth_userid', defaultval:'fun_getUserId()', anchor:'100%'}				]			});						//添加缺省值			var form = printForm.getForm();			form.set('money_plan__auth_userid', JxDefault.getUserId());						var self = this;			//创建对话框			var win = new Ext.Window({				title:	'批复下达',				layout:'fit',				width:400,				height:170,				resizable: false,				modal: true,				closeAction:'close',				items:[printForm],				buttons: [{					text:jx.base.ok,		//'确定'					handler:function(){						//数据校验						if (!form.isValid()) {							JxHint.alert(jx.event.datavalid);	//'请确保输入的数据正确完整！'							return;						}						self.exeCheck(planids, form);						win.close();					}				},{					text:jx.base.cancel,	//'取消'					handler:function(){win.close();}				}]			});			win.show();		}
	};
		
	return new Jxstar.GridNode(config);
}